package TOP101;

/**
 * @Question BM22
 * @Date 2022/11/9 11:07
 * @Solution
 */
public class BM22 {
    public int compare (String version1, String version2) {
        String[] v1 = version1.split("\\.");
        String[] v2 = version2.split("\\.");
        int dex1=0,dex2=0;
        while(dex1<v1.length && dex2<v2.length) {
            int s=Integer.parseInt(v1[dex1]);
            int b=Integer.parseInt(v2[dex2]);
            if(s>b) {
                return 1;
            } else if(s<b){
                return -1;
            } else {
                dex1++;
                dex2++;
            }
        }
        while(dex1<v1.length) {
            if(Integer.parseInt(v1[dex1])!=0) {
                return 1;
            }
            dex1++;
        }
        while(dex2<v2.length) {
            if(Integer.parseInt(v2[dex2])!=0) {
                return -1;
            }
            dex2++;
        }
        return 0;
    }
}
